import './global';
import * as React from 'react';
import { runApp } from 'ice';
import LocaleProvider from '@/components/LocaleProvider';

const appConfig = {
  app: {
    getInitialData: async () => {
      // 模拟服务端返回的数据
    },
    rootId: 'ice-container',
    errorBoundary: true,
    addProvider: ({ children }) => <LocaleProvider>{children}</LocaleProvider>,
  },
  router: {
    // modifyRoutes: (routes) => {
    //   // 根据服务器授权过滤路由配置
    //   let endpoints = persist.getObject('endpoints');

    //   if (endpoints) {
    //     let filterRoutes = [...routes];
    //     filterRoutes[1].children = filterRoutes[1].children.reduce((pre, cur) => {
    //       console.log('-------', cur.path);
    //       endpoints.map(v => {
    //         if (v.path == cur.path) pre.push(cur)
    //       })
    //       return pre
    //     }, []);
    //     filterRoutes[1].children.push({
    //       path: '/',
    //       redirect: '/dashboard',
    //     }, { component: NotFound, })
    //     return filterRoutes;
    //   } else {
    //     return routes
    //   }

    // }
  },
};
runApp(appConfig);
